package com.fp.m7.shared.services;

import java.util.List;

import com.fp.m7.shared.dto.UserDto;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;

public interface FollowServiceAsync {

    void follow(UserDto userDto, AsyncCallback<Boolean> callback);

    void unfollow(UserDto userDto, AsyncCallback<Boolean> callback);

    void listFollowed(AsyncCallback<List<UserDto>> callback);

    void listFollowers(AsyncCallback<List<UserDto>> callback);

    void countFollowed(AsyncCallback<Integer> callback);

    void countFollowers(AsyncCallback<Integer> callback);

    void listFollowed(UserDto userDto, AsyncCallback<List<UserDto>> callback);

    void listFollowers(UserDto userDto, AsyncCallback<List<UserDto>> callback);

    void countFollowed(UserDto userDto, AsyncCallback<Integer> callback);

    void countFollowers(UserDto userDto, AsyncCallback<Integer> callback);

    /**
     * Utility class to get the RPC Async interface from client-side code
     */
    public static final class Util {
        private static FollowServiceAsync instance;

        public static FollowServiceAsync getInstance() {
            if (instance == null) {
                instance = (FollowServiceAsync) GWT.create(FollowService.class);
            }
            return instance;
        }

        private Util() {
            // Utility class should not be instantiated
        }
    }
}
